package com.suitsoft.ut.service.system;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;

import com.suitsoft.ut.dao.HibernateUtils;
import com.suitsoft.ut.dao.account.SystemDao;
import com.suitsoft.ut.entity.account.Role;
import com.suitsoft.ut.entity.account.SubSystem;

/**
 * 系统管理 服务层类
 *@author Suineg
 */
@Service
@Transactional
public class SystemManager {
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private SystemDao systemDao;
	
	public SubSystem get(Long id){
		return systemDao.get(id);
	}
	
	public void save(SubSystem system,List<Long> checkIds){
		HibernateUtils.mergeByCheckedIds(system.getRoleList(), checkIds, Role.class);
		systemDao.save(system);
	}
	
	public void delete(Long id){
		systemDao.delete(id);
	}

	public Page<SubSystem> searchSystem(Page<SubSystem> page,List<PropertyFilter> filters) {
		return systemDao.findPage(page, filters);
	}
	
	public List<SubSystem> getAll(){
		return systemDao.getAll();
	}
}

